/*
 * 文件名:User.java
 * 创建时间:2009-03-10
 * 版本:1.0
 * 版权所有:杨涛
 */
package com.yangtao.prototype.system.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import com.yangtao.framework.constant.User;
import com.yangtao.framework.hibernate.BaseEntity;

/**
 * 基础实体，用户
 * 
 * @see SysUser
 * @author 杨涛
 * @创建时间:2009-03-10
 * @修改者:
 * @修改时间:
 * @修改原因:
 * @version:1.0
 */
@Entity()
@Table(name = "sys_user")
public class SysUser extends BaseEntity implements User {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 用户代码
	 */
	@Column(length = 20)
	private String userCode;
	/**
	 * 用户名称
	 */
	@Column(length = 200)
	private String userName;
	/**
	 * 用户类型
	 */
	@Column(length = 20)
	private String userType;
	/**
	 * 用户密码
	 */
	@Column(length = 50)
	private String password;
	/**
	 * 电话
	 */
	@Column(length = 20)
	private String telephone;
	/**
	 * 手机
	 */
	@Column(length = 20)
	private String phone;
	/**
	 * E-mail
	 */
	@Column(length = 30)
	private String email;
	/**
	 * 地址1
	 */
	@Column(length = 100)
	private String address1;
	/**
	 * 地址2
	 */
	@Column(length = 100)
	private String address2;
	/**
	 * 地址3
	 */
	@Column(length = 100)
	private String address3;
	/**
	 * 是否启用
	 */
	@Column(length = 1)
	private Byte isActive;
	/**
	 * 过期日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	private Date expireDate;
	/**
	 * 最后一次登陆时间
	 */
	@Temporal(TemporalType.TIMESTAMP)
	private Date lstLogon;

	/**
	 * 所属组织机构
	 */
	@ManyToOne()
	@JoinColumn(name = "orgId")
	private Organize orgnize;

	/**
	 * 公司ID
	 */
	@Column(length = 32)
	private String companyId;
	/**
	 * 创建时间
	 */
	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;
	/**
	 * 创建人Id
	 */
	private String createById;
	/**
	 * 创建人名称
	 */
	private String createByName;

	/**
	 * 用户和用户角色的关系配置，为一对多的配置
	 */
	@OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
	@Cascade(CascadeType.ALL)
	private List<UserRole> roles;

	@OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
	@Cascade(CascadeType.ALL)
	private List<DataAuthority> dataAuth;

	/**
	 * @return the dataAuth
	 */
	public List<DataAuthority> getDataAuth() {
		return dataAuth;
	}

	/**
	 * @param dataAuth
	 *            the dataAuth to set
	 */
	public void setDataAuth(List<DataAuthority> dataAuth) {
		this.dataAuth = dataAuth;
	}

	/**
	 * @return the userCode
	 */
	public String getUserCode() {
		return userCode;
	}

	/**
	 * @param userCode
	 *            the userCode to set
	 */
	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}

	/**
	 * @return the userName
	 */
	public String getUserName() {
		return userName;
	}

	/**
	 * @param userName
	 *            the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the expireDate
	 */
	public Date getExpireDate() {
		return expireDate;
	}

	/**
	 * @param expireDate
	 *            the expireDate to set
	 */
	public void setExpireDate(Date expireDate) {
		this.expireDate = expireDate;
	}

	/**
	 * @return the lstLogon
	 */
	public Date getLstLogon() {
		return lstLogon;
	}

	/**
	 * @param lstLogon
	 *            the lstLogon to set
	 */
	public void setLstLogon(Date lstLogon) {
		this.lstLogon = lstLogon;
	}

	/**
	 * @return the userType
	 */
	public String getUserType() {
		return userType;
	}

	/**
	 * @param userType
	 *            the userType to set
	 */
	public void setUserType(String userType) {
		this.userType = userType;
	}

	public Organize getOrgnize() {
		return orgnize;
	}

	public void setOrgnize(Organize orgnize) {
		this.orgnize = orgnize;
	}

	public String getCompanyId() {
		return companyId;
	}

	public void setCompanyId(String companyId) {
		this.companyId = companyId;
	}

	/**
	 * @return the roles
	 */
	public List<UserRole> getRoles() {
		return roles;
	}

	/**
	 * @param roles
	 *            the roles to set
	 */
	public void setRoles(List<UserRole> roles) {
		this.roles = roles;
	}

	/**
	 * @return the telephone
	 */
	public String getTelephone() {
		return telephone;
	}

	/**
	 * @param telephone
	 *            the telephone to set
	 */
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	/**
	 * @return the phone
	 */
	public String getPhone() {
		return phone;
	}

	/**
	 * @param phone
	 *            the phone to set
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the address1
	 */
	public String getAddress1() {
		return address1;
	}

	/**
	 * @param address1
	 *            the address1 to set
	 */
	public void setAddress1(String address1) {
		this.address1 = address1;
	}

	/**
	 * @return the address2
	 */
	public String getAddress2() {
		return address2;
	}

	/**
	 * @param address2
	 *            the address2 to set
	 */
	public void setAddress2(String address2) {
		this.address2 = address2;
	}

	/**
	 * @return the address3
	 */
	public String getAddress3() {
		return address3;
	}

	/**
	 * @param address3
	 *            the address3 to set
	 */
	public void setAddress3(String address3) {
		this.address3 = address3;
	}

	/**
	 * @return the isActive
	 */
	public Byte getIsActive() {
		return isActive;
	}

	/**
	 * @param isActive
	 *            the isActive to set
	 */
	public void setIsActive(Byte isActive) {
		this.isActive = isActive;
	}

	/**
	 * @return the createTime
	 */
	public Date getCreateTime() {
		return createTime;
	}

	/**
	 * @param createTime
	 *            the createTime to set
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	/**
	 * @return the createById
	 */
	public String getCreateById() {
		return createById;
	}

	/**
	 * @param createById the createById to set
	 */
	public void setCreateById(String createById) {
		this.createById = createById;
	}

	/**
	 * @return the createByName
	 */
	public String getCreateByName() {
		return createByName;
	}

	/**
	 * @param createByName the createByName to set
	 */
	public void setCreateByName(String createByName) {
		this.createByName = createByName;
	}
}
